const axios = require('axios');
const fetch = require('../common/fetch');

export function getDataSourceList() {
    return fetch('/crawl/getDataSourceList').then(ret => ret.data);
}
export function getDataSourceById(data_source_id) {
    return fetch(`/crawl/getDataSourceById/${data_source_id}`).then(ret => ret.data);
}
export function saveDataSource(data) {
    return axios.post('/crawl/saveDataSource', data).then(ret => ret.data);
}

export function getGrabSourceList() {
    return fetch('/crawl/getGrabSourceList').then(ret => ret.data);
}
export function getGrabSourceById(station_id) {
    return fetch(`/crawl/getGrabSourceById/${station_id}`).then(ret => ret.data);
}
export function saveGrabSource(data) {
    return axios.post('/crawl/saveGrabSource', data).then(ret => ret.data);
}

export function getRuleList() {
    return fetch('/crawl/getRuleList').then(ret => ret.data);
}
export function getRuleInfoById(config_id) {
    return fetch(`/crawl/getRuleInfoById/${config_id}`).then(ret => ret.data);
}
export function saveRuleInfo(data) {
    return axios.post('/crawl/saveRuleInfo', data).then(ret => ret.data);
}
export function deleteRuleInfo(config_id) {
    return fetch(`/crawl/deleteRuleInfo/${config_id}`).then(ret => ret.data);
}

export function getStorageModelList() {
    return fetch('/crawl/getStorageModelList').then(ret => ret.data);
}
export function getStorageModelById(model_id) {
    return fetch(`/crawl/getStorageModelById/${model_id}`).then(ret => ret.data);
}
export function saveStorageModel(data) {
    return axios.post('/crawl/saveStorageModel', data).then(ret => ret.data);
}
export function deleteStorageModel(model_id) {
    return fetch(`/crawl/deleteStorageModel/${model_id}`).then(ret => ret.data);
}

export function getCategoryList() {
    return fetch('/crawl/getCategoryList').then(ret => ret.data);
}
export function getCategoryById(category_id) {
    return fetch(`/crawl/getCategoryById/${category_id}`).then(ret => ret.data);
}
export function getCategoryTree() {
    return fetch('/crawl/getCategoryTree').then(ret => ret.data);
}
export function saveCategory(data) {
    return axios.post('/crawl/saveCategory', data).then(ret => ret.data);
}

export function getInfoTypeList() {
    return fetch('/crawl/getInfoTypeList').then(ret => ret.data);
}
export function getInfoTypeById(info_type_id) {
    return fetch(`/crawl/getInfoTypeById/${info_type_id}`).then(ret => ret.data);
}
export function saveInfoType(data) {
    return axios.post('/crawl/saveInfoType', data).then(ret => ret.data);
}

export function getMonitorConfList() {
    return fetch('/crawl/getMonitorConfList').then(ret => ret.data);
}
export function getMonitorConfById(monitor_id) {
    return fetch(`/crawl/getMonitorConfById/${monitor_id}`).then(ret => ret.data);
}
export function saveMonitorConf(data) {
    return axios.post('/crawl/saveMonitorConf', data).then(ret => ret.data);
}

export function getBusinessDetailsList() {
    return fetch('/crawl/getBusinessDetailsList').then(ret => ret.data);
}
export function getBusinessDetailsById(businessId) {
    return fetch(`/crawl/getBusinessDetailsById/${businessId}`).then(ret => ret.data);
}
export function saveBusinessDetails(data) {
    return axios.post('/crawl/saveBusinessDetails', data).then(ret => ret.data);
}
export function getQueueLength(queueName) {
    return fetch(`/crawl/getQueueLength/${queueName}`).then(ret => ret.data);
}

export function testRule(data) {
    return axios.post('/crawl/testRule', data).then(ret => ret.data);
}
export function getTestRuleResult(data) {
    return axios.post('/crawl/getTestRuleResult', data).then(ret => ret.data);
}
export function saveTestRuleResult(data) {
    return axios.post('/crawl/saveTestRuleResult', data).then(ret => ret.data);
}
